package view.screen;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextField;

import view.base.FormScreen;
import base.ScreenActionListener;
import controller.Controller;

public final class MessageScreen extends FormScreen {
	
	private final TextField message;
	
	public MessageScreen(ScreenActionListener controller){
		super(controller, "Message");
		
		message = new TextField("Message",null,50,TextField.ANY);
		
		this.append(message);
		
		this.addCommand(new Command("Send", Command.OK, 1));
		
		this.setCommandListener(this);
	}
	
	public void commandAction(Command c, Displayable d) {
		String msg = message.getString();
		if(msg.equals(""))
			return;
		switch (c.getCommandType()) {
		case Command.OK:
				controller.viewAction(Controller.SEND_COMMAND, msg);
		default:
			super.commandAction(c, d);
			break;
		}
	}

}
